package com.rental.web.controller;

import com.rental.ai.AiClient;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "AI模块")
@RequestMapping("/ai")
@Lazy
public class AiController {
    @Autowired
    private AiClient aiClient;

    @Operation(summary = "Ai对话")
    @PostMapping("send")
    public String aiTalk(@RequestBody String question) {
        try {
            return aiClient.aiTalk(question);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
